#e
#Title[X|uXv]
#Text[ӉiԂ̃XyJ[h]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let name    = "X|uXv";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\dot_eirin.png";
	let Animation=0;
	let AnimationA=0;
	let EirinMotion=0;

    // ʒu

    @Initialize {
    CutIn(YOUMU, name, 0, 0, 0, 0, 0);

        SetLife(3000);
        SetTimer(70);
        SetScore(1000000);
        SetDamageRate(100,100);
        SetInvincibility(180);
        SetMovePosition02(cx,120,60);
	LoadGraphic(imgBoss);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime;
    }

        @MainLoop
        {
        	
        	if( count % 30 == 0 && count >= 60 && count <= 90)
        	{
			Concentration01(60);
        	}
        	if(count==100)
        	{
			TAnime3;
			EirinMotion=1;
        	}
        	if(count==120)
        	{
			let i=0;
			while(i<20)
			{
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX()+10,GetY()-35,i);
			SetShotDataA_XY(shotA,0,rand(-1,1),rand(-4,-2),rand(-0.5,0.5),rand(0.1,0.2),rand(-1,1),rand(3,5),1);
			let j=20;
			while(j<100)
			{
        			SetShotDirectionType(ABSOLUTE);
				let ta=1;
				CreateShotA(ta,0,0,5);
				SetShotDataA(ta,0,0,rand(0,360),0,0,0,2);
				SetShotDataA(ta,60,0,NULL,0,0.005,3,2);
				AddShot(j,shotA,ta,0);
				j=j+5;
			}
			FireShot(shotA);
			i=i+1;
			}
        	}
        	if(count>=180&&count%180==100)
        	{
			TAnime3;
			EirinMotion=1;
        	}
        	if(count>=180&&count%180==120)
        	{
			let i=0;
			while(i<20)
			{
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX()+10,GetY()-35,i);
			SetShotDataA_XY(shotA,0,rand(-1,1),rand(-4,-2),rand(-0.5,0.5),rand(0.1,0.2),rand(-1,1),rand(3,5),1);
			let j=20;
			while(j<100)
			{
        			SetShotDirectionType(ABSOLUTE);
				let ta=1;
				CreateShotA(ta,0,0,5);
				SetShotDataA(ta,0,0,rand(0,360),0,0,0,2);
				SetShotDataA(ta,120,0,NULL,0,0.005,3,2);
				AddShot(j,shotA,ta,0);
				j=j+5;
			}
			FireShot(shotA);
			i=i+1;
			}
			let i=0;
			while(i<250)
			{
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX+cos(150+i)*20,GetY+sin(150+i)*20,0);
			SetShotDataA(shotA,0,3,150+i,0,0,3,BLUE03);
			FireShot(shotA);
			CreateShotA(shotA,GetX+cos(150+i)*20,GetY+sin(150+i)*20,0);
			SetShotDataA(shotA,0,4,150+i,0,0,4,BLUE03);
			FireShot(shotA);
			CreateShotA(shotA,GetX+cos(150+i)*20,GetY+sin(150+i)*20,0);
			SetShotDataA(shotA,0,5,150+i,0,0,5,BLUE03);
			FireShot(shotA);
			i=i+10;
			}
        	}
        	if(count>=180&&count%180==150)
        	{
			EirinMotion=0;
        	}
	if(count>=180&&count%180==0){
			TAnime2;
			EirinMotion=0;
			SetMovePositionRandom01(rand(25,75),rand(25,75),2,GetClipMinX()+100,75,GetClipMaxX()-100,150);
		}
		SetCollisionA(GetX(),GetY(),32);
            SetCollisionB(GetX(),GetY(),24);
            count++;
        yield;
        }

        @DrawLoop {
	if(EirinMotion==0){

		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
		SetAlpha(255);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(0,128*Animation,127,127+128*Animation);}
		else if(GetSpeedX()>0){SetGraphicRect(256,256+128*AnimationA,383,383+128*AnimationA);}
		else if(GetSpeedX()<0){SetGraphicRect(256,128*AnimationA,383,127+128*AnimationA);}
		DrawGraphic(GetX(),GetY());
		}
	if(EirinMotion==1){
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetGraphicRect(640,128*AnimationA,767,127+128*AnimationA);
		DrawGraphic(GetX(),GetY());
		}
    }

    @Finalize {
        DeleteGraphic(imgBoss);
    }
    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}

    	task TAnime2{
			AnimationA=0;
        		loop(10){yield;}
			AnimationA=1;
        		loop(30){yield;}
			AnimationA=0;
        		loop(10){yield;}
		}

    	task TAnime3{
			AnimationA=0;
        		loop(5){yield;}
			AnimationA=1;
        		loop(5){yield;}
			AnimationA=2;
        		loop(30){yield;}
			AnimationA=1;
        		loop(5){yield;}
			AnimationA=0;
        		loop(5){yield;}
		}
}